//
// Created by ub on 2020/11/1.
//
#include <iostream>
using namespace std;
const int Max = 5;
int fill_array(double ar[] , int limit);
void show_array(const double ar[] ,int n);
void revalue(double r , double ar[] , int n);
/*int main()
{
   double properties[Max];
   int size = fill_array(properties,Max);
   show_array(properties,size);
   if (size >0)
   {
     cout << "Enter revaluation factor :";
     double factor;
     while (!(cin >> factor))
     {
       cin.clear();
       while (cin.get()!='\n') continue;
       cout << "Bad input;Please enter a number: ";
     }
     revalue(factor,properties,size);
     show_array(properties,size);
   }
   cout << "Done.\n";
   cin.get();
   cin.get();
   return 0;
}*/
/**
 * 填充数组
 * @param ar
 * @param limit
 * @return 返回填充的元素长度
 */
int fill_array(double ar[] , int limit)
{
    double temp;
    int i;
    for (i =0 ;i<limit ;++i)
    {
       cout << "Enter value # " << (i+1) << ": ";
       cin >> temp;
       if(!cin)
       {
         cin.clear();
         while (cin.get() != '\n') continue;
         cout << "Bad input; input process terinated.\n";
         break;
       }
       else if (temp < 0) break;
       ar[i] = temp;
    }
    return i;
}
/**
 * 显示数组元素
 * @param ar
 * @param n
 */
void show_array(const double ar[] ,int n)
{
    for (int i =0;i<n;++i)
    {
       cout <<"Property #" << (i+1) << ": $";
       cout << ar[i] << endl;
    }
}
/*
 * 修改数组元素
 */
void revalue (double r , double ar[] , int n)
{
   for (int i=0;i<n;++i)
     ar[i]*=r;
}